<?php
/**
 *      [Elitechmedia!] (C)2001-2099 MYSELF Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: addproduction.php 22609 2013-10-16 01:55:33Z zhangchaofeng
 */
if(!isset($_SESSION)){
	session_start();
}
if(!$_SESSION['uid']){
	require_once "tmp/login.htm";exit;
}
include_once("classes/DB.class.php");
include_once("classes/page.class.php");
include_once("function/member.php");
include_once("function/util.func.php");
date_default_timezone_set('Asia/Shanghai');

$uid=$_SESSION['uid'];
$cid=$_SESSION['c_id'];
if($cid==-1):
$message="<font color='red'>对不起你还没有自己的企业无法下计划...!!</font>";
$text="如果您的浏览器没有自动跳转，请点击这里";
$url="production.php";
include 'tmp/error.htm';exit;
endif;

$id=addslashes($_REQUEST['id']);
if($id!=''):
$info = $GLOBALS["DB"]->result("SELECT * FROM production where id='$id'");
$info=$info[0];
endif;
if($_SERVER['REQUEST_METHOD'] == 'POST'):
	$data['p_no']=addslashes($_POST['p_no']);
	$upid=$_POST['upid'];
	if($data['p_no']!=''):
		if($_SESSION['c_id']==0):
		$data['c_id']=addslashes($_POST['c_id']);
		else:
		$data['c_id']=$_SESSION['c_id'];
		endif;
		$data['end_date_time']=strtotime($_POST['end_date_time']);
		$data['number']=addslashes($_POST['number']);
		$data['outer_ring_num']=addslashes($_POST['outer_ring_num']);
		$data['inner_ring_num']=addslashes($_POST['inner_ring_num']);
		$data['rolling_element_num']=addslashes($_POST['rolling_element_num']);
		$data['retainer_num']=addslashes($_POST['retainer_num']);
		$data['first_p_id']=addslashes($_POST['first_p_id']);
		if($upid!=''):
			$GLOBALS["DB"]->execute_event("update production set ".implode_field_value($data) ." where id='$upid'");
			$message="<font color='green'>您的操作已经成功....</font>";
			$text="如果您的浏览器没有自动跳转，请点击这里";
			$url="production.php";
			include 'tmp/success.htm';exit;
		else:
			$data['create_time']=time();
			$fid = $GLOBALS["DB"]->execute_event("INSERT INTO production set ".implode_field_value($data));
			if(!$fid):
				$message="<font color='red'>对不起数据保存失败.!!</font>";
				$text="如果您的浏览器没有自动跳转，请点击这里";
				$url="production.php";
				include 'tmp/error.htm';exit;
			else:
				$message="<font color='green'>您的操作已经成功....</font>";
				$text="如果您的浏览器没有自动跳转，请点击这里";
				$url="production.php";
				include 'tmp/success.htm';exit;
			endif;
		endif;
	else:
		$message="<font color='red'>编号不能为空...!!</font>";
		$text="如果您的浏览器没有自动跳转，请点击这里";
		$url="production.php";
		include 'tmp/error.htm';exit;
	endif;
endif;

$p_data = $GLOBALS["DB"]->result("SELECT id,p_name FROM process where c_id='$cid' ORDER BY id DESC ");

include 'tmp/addproduction.htm';